const mongoose = require("mongoose");
const moment = require('moment');
const Schema = mongoose.Schema;

/**
 * 系统字典
 */
const SysDict = new Schema({
  dictName: String,
  dictType: String,
  remark: String,
  status: Number,
  createTime: String,
  updateTime: String,
}, {
  timestamps: {
    createdAt: 'createTime',
    updatedAt: 'updateTime',
    currentTime: () => moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
  }
})

const SysDictList = mongoose.model("sys_dicts", SysDict)

/**
 * 字典关联表
 */
const SysDictValue = new Schema({
  dictType: String,
  dictLabel: String,
  dictValue: String,
  remark: String,
  status: Number,
  dictSort: String,
  createTime: String,
  updateTime: String,
}, {
  timestamps: {
    createdAt: 'createTime',
    updatedAt: 'updateTime',
    currentTime: () => moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
  }
})

const SysDictValueList = mongoose.model("sys_dict_values", SysDictValue)

/**
 * 整体导出
 */
module.exports = {
  SysDictList,
  SysDictValueList,
};